package com.ruoyi.monitor.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.monitor.domain.MonitorVideo;
import com.ruoyi.monitor.service.IMonitorVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 监控视频Controller
 * 
 * @author ruoyi
 * @date 2025-04-16
 */
@RestController
@RequestMapping("/monitor/video")
public class MonitorVideoController extends BaseController
{
    @Autowired
    private IMonitorVideoService monitorVideoService;

    /**
     * 查询监控视频列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:video:list')")
    @GetMapping("/list")
    public TableDataInfo list(MonitorVideo monitorVideo)
    {
        startPage();
        List<MonitorVideo> list = monitorVideoService.selectMonitorVideoList(monitorVideo);
        return getDataTable(list);
    }

    /**
     * 导出监控视频列表
     */
    @PreAuthorize("@ss.hasPermi('monitor:video:export')")
    @Log(title = "监控视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MonitorVideo monitorVideo)
    {
        List<MonitorVideo> list = monitorVideoService.selectMonitorVideoList(monitorVideo);
        ExcelUtil<MonitorVideo> util = new ExcelUtil<MonitorVideo>(MonitorVideo.class);
        util.exportExcel(response, list, "监控视频数据");
    }

    /**
     * 获取监控视频详细信息
     */
    @PreAuthorize("@ss.hasPermi('monitor:video:query')")
    @GetMapping(value = "/{videoId}")
    public AjaxResult getInfo(@PathVariable("videoId") Integer videoId)
    {
        return success(monitorVideoService.selectMonitorVideoByVideoId(videoId));
    }

    /**
     * 新增监控视频
     */
    @PreAuthorize("@ss.hasPermi('monitor:video:add')")
    @Log(title = "监控视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MonitorVideo monitorVideo)
    {
        return toAjax(monitorVideoService.insertMonitorVideo(monitorVideo));
    }

    /**
     * 修改监控视频
     */
    @PreAuthorize("@ss.hasPermi('monitor:video:edit')")
    @Log(title = "监控视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MonitorVideo monitorVideo)
    {
        return toAjax(monitorVideoService.updateMonitorVideo(monitorVideo));
    }

    /**
     * 删除监控视频
     */
    @PreAuthorize("@ss.hasPermi('monitor:video:remove')")
    @Log(title = "监控视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{videoIds}")
    public AjaxResult remove(@PathVariable Integer[] videoIds)
    {
        return toAjax(monitorVideoService.deleteMonitorVideoByVideoIds(videoIds));
    }
}
